' The return data value is valid and different from the last sample.
'
Public Const PDH_CSTATUS_NEW_DATA = &H1
'
' Informational messages
'
' None
'
' Warning Messages
' These messages are returned when the function has completed
' successfully but the results may be different than expected.
'
'
' MessageId: PDH_CSTATUS_NO_MACHINE
'
' MessageText:
'
' Unable to connect to specified machine or machine is off line.
'
Public Const PDH_CSTATUS_NO_MACHINE = &H800007D0
'
' MessageId: PDH_CSTATUS_NO_INSTANCE
'
' MessageText:
'
' The specified instance is not present.
'
Public Const PDH_CSTATUS_NO_INSTANCE = &H800007D1
'
' MessageId: PDH_MORE_DATA
'
' MessageText:
'
' There is more data to return than would fit in the supplied buffer. Allocate
' a larger buffer and call the function again.
'
Public Const PDH_MORE_DATA = &H800007D2
'
' MessageId: PDH_CSTATUS_ITEM_NOT_VALIDATED
'
' MessageText:
'
' The data item has been added to the query, but has not been validated nor
' accessed. No other status information on this data item is available.
'
Public Const PDH_CSTATUS_ITEM_NOT_VALIDATED = &H800007D3
'
' MessageId: PDH_RETRY
'
' MessageText:
'
' The selected operation should be retried.
'
Public Const PDH_RETRY = &H800007D4
'
' MessageId: PDH_NO_DATA
'
' MessageText:
'
' No data to return.
'
Public Const PDH_NO_DATA = &H800007D5
'
' MessageId: PDH_CALC_NEGATIVE_DENOMINATOR
'
' MessageText:
'
' A counter with a negative denominator value was detected.
'
Public Const PDH_CALC_NEGATIVE_DENOMINATOR = &H800007D6
'
' MessageId: PDH_CALC_NEGATIVE_TIMEBASE
'
' MessageText:
'
' A counter with a negative timebase value was detected.
'
Public Const PDH_CALC_NEGATIVE_TIMEBASE = &H800007D7
'
' MessageId: PDH_CALC_NEGATIVE_VALUE
'
' MessageText:
'
' A counter with a negative value was detected.
'
Public Const PDH_CALC_NEGATIVE_VALUE = &H800007D8
'
' MessageId: PDH_DIALOG_CANCELLED
'
' MessageText:
'
' The user cancelled the dialog box.
'
Public Const PDH_DIALOG_CANCELLED = &H800007D9
'
' MessageId: PDH_END_OF_LOG_FILE
'
' MessageText:
'
' The end of the log file was reached.
'
Public Const PDH_END_OF_LOG_FILE = &H800007DA
'
' Error Messages
' These messages are returned when the function could not complete
' as requested and some corrective action may be required by the
' the caller or the user.
'
'
' MessageId: PDH_CSTATUS_NO_OBJECT
'
' MessageText:
'
' The specified object is not found on the system.
'
Public Const PDH_CSTATUS_NO_OBJECT = &HC0000BB8
'
' MessageId: PDH_CSTATUS_NO_COUNTER
'
' MessageText:
'
' The specified counter could not be found.
'
Public Const PDH_CSTATUS_NO_COUNTER = &HC0000BB9
'
' MessageId: PDH_CSTATUS_INVALID_DATA
'
' MessageText:
'
' The returned data is not valid.
'
Public Const PDH_CSTATUS_INVALID_DATA = &HC0000BBA
'
' MessageId: PDH_MEMORY_ALLOCATION_FAILURE
'
' MessageText:
'
' A PDH function could not allocate enough temporary memory to complete the
' operation. Close some applications or extend the pagefile and retry the
' function.
'
Public Const PDH_MEMORY_ALLOCATION_FAILURE = &HC0000BBB
'
' MessageId: PDH_INVALID_HANDLE
'
' MessageText:
'
' The handle is not a valid PDH object.
'
Public Const PDH_INVALID_HANDLE = &HC0000BBC
'
' MessageId: PDH_INVALID_ARGUMENT
'
' MessageText:
'
' A required argument is missing or incorrect.
'
Public Const PDH_INVALID_ARGUMENT = &HC0000BBD
'
' MessageId: PDH_FUNCTION_NOT_FOUND
'
' MessageText:
'
' Unable to find the specified function.
'
Public Const PDH_FUNCTION_NOT_FOUND = &HC0000BBE
'
' MessageId: PDH_CSTATUS_NO_COUNTERNAME
'
' MessageText:
'
' No counter was specified.
'
Public Const PDH_CSTATUS_NO_COUNTERNAME = &HC0000BBF
'
' MessageId: PDH_CSTATUS_BAD_COUNTERNAME
'
' MessageText:
'
' Unable to parse the counter path. Check the format and syntax of the
' specified path.
'
Public Const PDH_CSTATUS_BAD_COUNTERNAME = &HC0000BC0
'
' MessageId: PDH_INVALID_BUFFER
'
' MessageText:
'
' The buffer passed by the caller is invalid.
'
Public Const PDH_INVALID_BUFFER = &HC0000BC1
'
' MessageId: PDH_INSUFFICIENT_BUFFER
'
' MessageText:
'
' The requested data is larger than the buffer supplied. Unable to return the
' requested data.
'
Public Const PDH_INSUFFICIENT_BUFFER = &HC0000BC2
'
' MessageId: PDH_CANNOT_CONNECT_MACHINE
'
' MessageText:
'
' Unable to connect to the requested machine.
'
Public Const PDH_CANNOT_CONNECT_MACHINE = &HC0000BC3
'
' MessageId: PDH_INVALID_PATH
'
' MessageText:
'
' The specified counter path could not be interpreted.
'
Public Const PDH_INVALID_PATH = &HC0000BC4
'
' MessageId: PDH_INVALID_INSTANCE
'
' MessageText:
'
' The instance name could not be read from the specified counter path.
'
Public Const PDH_INVALID_INSTANCE = &HC0000BC5
'
' MessageId: PDH_INVALID_DATA
'
' MessageText:
'
' The data is not valid.
'
Public Const PDH_INVALID_DATA = &HC0000BC6
'
' MessageId: PDH_NO_DIALOG_DATA
'
' MessageText:
'
' The dialog box data block was missing or invalid.
'
Public Const PDH_NO_DIALOG_DATA = &HC0000BC7
'
' MessageId: PDH_CANNOT_READ_NAME_STRINGS
'
' MessageText:
'
' Unable to read the counter and/or explain text from the specified machine.
'
Public Const PDH_CANNOT_READ_NAME_STRINGS = &HC0000BC8
'
' MessageId: PDH_LOG_FILE_CREATE_ERROR
'
' MessageText:
'
' Unable to create the specified log file.
'
Public Const PDH_LOG_FILE_CREATE_ERROR = &HC0000BC9
'
' MessageId: PDH_LOG_FILE_OPEN_ERROR
'
' MessageText:
'
' Unable to open the specified log file.
'
Public Const PDH_LOG_FILE_OPEN_ERROR = &HC0000BCA
'
' MessageId: PDH_LOG_TYPE_NOT_FOUND
'
' MessageText:
'
' The specified log file type has not been installed on this system.
'
Public Const PDH_LOG_TYPE_NOT_FOUND = &HC0000BCB
'
' MessageId: PDH_NO_MORE_DATA
'
' MessageText:
'
' No more data is available.
'
Public Const PDH_NO_MORE_DATA = &HC0000BCC
'
' MessageId: PDH_ENTRY_NOT_IN_LOG_FILE
'
' MessageText:
'
' The specified record was not found in the log file.
'
Public Const PDH_ENTRY_NOT_IN_LOG_FILE = &HC0000BCD
'
' MessageId: PDH_DATA_SOURCE_IS_LOG_FILE
'
' MessageText:
'
' The specified data source is a log file.
'
Public Const PDH_DATA_SOURCE_IS_LOG_FILE = &HC0000BCE
'
' MessageId: PDH_DATA_SOURCE_IS_REAL_TIME
'
' MessageText:
'
' The specified data source is the current activity.
'
Public Const PDH_DATA_SOURCE_IS_REAL_TIME = &HC0000BCF
'
' MessageId: PDH_UNABLE_READ_LOG_HEADER
'
' MessageText:
'
' The log file header could not be read.
'
Public Const PDH_UNABLE_READ_LOG_HEADER = &HC0000BD0
'
' MessageId: PDH_FILE_NOT_FOUND
'
' MessageText:
'
' Unable to find the specified file.
'
Public Const PDH_FILE_NOT_FOUND = &HC0000BD1
'
' MessageId: PDH_FILE_ALREADY_EXISTS
'
' MessageText:
'
' There is already a file with the specified file name.
'
Public Const PDH_FILE_ALREADY_EXISTS = &HC0000BD2
'
' MessageId: PDH_NOT_IMPLEMENTED
'
' MessageText:
'
' The function referenced has not been implemented.
'
Public Const PDH_NOT_IMPLEMENTED = &HC0000BD3
'
' MessageId: PDH_STRING_NOT_FOUND
'
' MessageText:
'
' Unable to find the specified string in the list of performance name and
' explain text strings.
'
Public Const PDH_STRING_NOT_FOUND = &HC0000BD4
'
' MessageId: PDH_UNABLE_MAP_NAME_FILES
'
' MessageText:
'
' Unable to map to the performance counter name data files. The data
' will be read from the registry and stored locally.
'
Public Const PDH_UNABLE_MAP_NAME_FILES = &H80000BD5
'
' MessageId: PDH_UNKNOWN_LOG_FORMAT
'
' MessageText:
'
' The format of the specified log file is not recognized by the PDH DLL.
'
Public Const PDH_UNKNOWN_LOG_FORMAT = &HC0000BD6
'
' MessageId: PDH_UNKNOWN_LOGSVC_COMMAND
'
' MessageText:
'
' The specified Log Service command value is not recognized.
'
Public Const PDH_UNKNOWN_LOGSVC_COMMAND = &HC0000BD7
'
' MessageId: PDH_LOGSVC_QUERY_NOT_FOUND
'
' MessageText:
'
' The specified Query from the Log Service could not be found or could not
' be opened.
'
Public Const PDH_LOGSVC_QUERY_NOT_FOUND = &HC0000BD8
'
' MessageId: PDH_LOGSVC_NOT_OPENED
'
' MessageText:
'
' The Performance Data Log Service key could not be opened. This may be due
' to insufficient privilege or because the service has not been installed.
'
Public Const PDH_LOGSVC_NOT_OPENED = &HC0000BD9
Public Function GetPdhReturn(ByVal PdhReturnCode As Long) As String
If PdhReturnCode And STATUS_SEVERITY_INFORMATIONAL Then Debug.Print "Informational"
If PdhReturnCode And STATUS_SEVERITY_WARNING Then Debug.Print "Warning"
If PdhReturnCode And STATUS_SEVERITY_ERROR Then
Select Case PdhReturnCode
Case PDH_CSTATUS_VALID_DATA
GetPdhReturn = "The returned data is valid."
Case PDH_CSTATUS_NEW_DATA
GetPdhReturn = "The return data value is valid and different from the last sample."
Case PDH_CSTATUS_NO_MACHINE
GetPdhReturn = "Unable to connect to specified machine or machine is off line."
Case PDH_CSTATUS_NO_INSTANCE
GetPdhReturn = "The specified instance is not present."
Case PDH_MORE_DATA
GetPdhReturn = "There is more data to return than would fit in the supplied buffer. Allocate a larger buffer and call the function again."
Case PDH_CSTATUS_ITEM_NOT_VALIDATED
GetPdhReturn = "The data item has been added to the query, but has not been validated nor accessed. No other status information on this data item is available."
Case PDH_RETRY
GetPdhReturn = "The selected operation should be retried."
Case PDH_NO_DATA
GetPdhReturn = "No data to return."
Case PDH_CALC_NEGATIVE_DENOMINATOR
GetPdhReturn = "A counter with a negative denominator value was detected."
Case PDH_CALC_NEGATIVE_TIMEBASE
GetPdhReturn = "A counter with a negative timebase value was detected."
Case PDH_CALC_NEGATIVE_VALUE
GetPdhReturn = "A counter with a negative value was detected."
Case PDH_DIALOG_CANCELLED
GetPdhReturn = "The user cancelled the dialog box."
Case PDH_END_OF_LOG_FILE
GetPdhReturn = "The end of the log file was reached."
Case PDH_CSTATUS_NO_OBJECT
GetPdhReturn = "The specified object is not found on the system."
Case PDH_CSTATUS_NO_COUNTER
GetPdhReturn = "The specified counter could not be found."
Case PDH_CSTATUS_INVALID_DATA
GetPdhReturn = "The returned data is not valid."
Case PDH_MEMORY_ALLOCATION_FAILURE
GetPdhReturn = "A PDH function could not allocate enough temporary memory to complete the operation. Close some applications or extend the pagefile and retry the function."
Case PDH_INVALID_HANDLE
GetPdhReturn = "The handle is not a valid PDH object."
Case PDH_INVALID_ARGUMENT
GetPdhReturn = "A required argument is missing or incorrect."
Case PDH_FUNCTION_NOT_FOUND
GetPdhReturn = "Unable to find the specified function."
Case PDH_CSTATUS_NO_COUNTERNAME
GetPdhReturn = "No counter was specified."
Case PDH_CSTATUS_BAD_COUNTERNAME
GetPdhReturn = "Unable to parse the counter path. Check the format and syntax of the specified path."
Case PDH_INVALID_BUFFER
GetPdhReturn = "The buffer passed by the caller is invalid."
Case PDH_INSUFFICIENT_BUFFER
GetPdhReturn = "The requested data is larger than the buffer supplied. Unable to return the requested data."
Case PDH_CANNOT_CONNECT_MACHINE
GetPdhReturn = "Unable to connect to the requested machine."
Case PDH_INVALID_PATH
GetPdhReturn = "The specified counter path could not be interpreted."
Case PDH_INVALID_INSTANCE
GetPdhReturn = "The instance name could not be read from the specified counter path."
Case PDH_INVALID_DATA
GetPdhReturn = "The data is not valid."
Case PDH_NO_DIALOG_DATA
GetPdhReturn = "The dialog box data block was missing or invalid."
Case PDH_CANNOT_READ_NAME_STRINGS
GetPdhReturn = "Unable to read the counter and/or explain text from the specified machine."
Case PDH_LOG_FILE_CREATE_ERROR
GetPdhReturn = "Unable to create the specified log file."
Case PDH_LOG_FILE_OPEN_ERROR
GetPdhReturn = "Unable to open the specified log file."
Case PDH_LOG_TYPE_NOT_FOUND
GetPdhReturn = "The specified log file type has not been installed on this system."
Case PDH_NO_MORE_DATA
GetPdhReturn = "No more data is available."
Case PDH_ENTRY_NOT_IN_LOG_FILE
GetPdhReturn = "The specified record was not found in the log file."
Case PDH_DATA_SOURCE_IS_LOG_FILE
GetPdhReturn = "The specified data source is a log file."
Case PDH_DATA_SOURCE_IS_REAL_TIME
GetPdhReturn = "The specified data source is the current activity."
Case PDH_UNABLE_READ_LOG_HEADER
GetPdhReturn = "The log file header could not be read."
Case PDH_FILE_NOT_FOUND
GetPdhReturn = "Unable to find the specified file."
Case PDH_FILE_ALREADY_EXISTS
GetPdhReturn = "There is already a file with the specified file name."
Case PDH_NOT_IMPLEMENTED
GetPdhReturn = "The function referenced has not been implemented."
Case PDH_STRING_NOT_FOUND
GetPdhReturn = "Unable to find the specified string in the list of performance name and explain text strings."
Case PDH_UNABLE_MAP_NAME_FILES
GetPdhReturn = "Unable to map to the performance counter name data files. The data will be read from the registry and stored locally."
Case PDH_UNKNOWN_LOG_FORMAT
GetPdhReturn = "The format of the specified log file is not recognized by the PDH DLL."
Case PDH_UNKNOWN_LOGSVC_COMMAND
GetPdhReturn = "The specified Log Service command value is not recognized."
Case PDH_LOGSVC_QUERY_NOT_FOUND
GetPdhReturn = "The specified Query from the Log Service could not be found or could not be opened."
Case PDH_LOGSVC_NOT_OPENED
GetPdhReturn = "The Performance Data Log Service key could not be opened. This may be due to insufficient privilege or because the service has not been installed."
Case Else
GetPdhReturn = "PDH Function could not be executed"